package com.lizemin.importcase.importSelector;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @author lzm
 * @date 2025/10/22 22:55
 * @description 数据源选择器
 */
public class DatasourceSelector implements ImportSelector {

    /**
     * 选择将哪些配置类注册到spring容器中
     *
     * @param importingClassMetadata 导入当前类的元注解信息
     * @return 配置类路径的数组
     */
    @Override
    @SuppressWarnings("all")
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        if (importingClassMetadata.isAnnotated(EnablePrd.class.getName())) {
            return new String[]{PrdDatasourceConfig.class.getName()};
        }
        return new String[]{DevDatasourceConfig.class.getName()};
    }
}
